import INode from './INode';

class Folder implements INode{
  name:string;
  children:Array<INode> = [];
  constructor(folderName:string){
    this.name = folderName;
  }
  add(node:INode):void{
    this.children.push(node);
  }
  remove(node:INode):void{
    let index = this.children.indexOf(node);
    this.children.splice(index, 1);
  }
  getChild(index:number):INode{
    return this.children[index];
  }
  killVirus():void{
    console.log(`查杀文件夹：${this.name}`);
    this.children.forEach(child=>{
      child.killVirus();
    });
  }
}

export {Folder};